<html>
<head></head>
<body>
<?php

include '../config.php';
// Passkey that got from link 
$passkey=$_GET['passkey'];
// Retrieve data from table where row that match this passkey 
$sql="SELECT * FROM user WHERE confirmcode ='$passkey'";
$result=mysql_query($sql);
if($result){
	$count=mysql_num_rows($result);
	if($count==1){
		echo "<script>alert('Your register was success');</script>";
		$row = mysql_fetch_array($result);
		$sql = "UPDATE user SET isConf=1 WHERE confirmcode='$passkey";
		$query = mysql_query($sql) or die(mysql_error());
		session_start();
		$_SESSION['user'] =$row['uName'];
  		$_SESSION['fName']=$row['Firstname'];
  		$_SESSION['lName']=$row['Lastname'];
  		header("Location: '../index.php'");
	} else {
		echo "<script>alert('Wrong Confirmation code');</script>";
	}
}
?>
</body>
</html>